pp108 : onchange Property

onchange Property


This is an optional property that contains the pointer to a function to be to be called when the description of a tree item is changed.

Syntax

XML

<TreeItem>
    <searchPath>sName</searchPath>
    <description>sDesc</description>
    <updateAllowed>bAllow</updateAllowed>
    <onchange>fpFunction</onchange>
        ...
        ...
        ...
</TreeItem>


Parameters

Parameter

Description

fpFunction

Pointer to a function that is to be called when the description of an item in the tree is changed


Remarks

Based on the return value of the function called on onchange, the description is changed on the item. If the return value for the function is set to 'false', the description does not change.

This property works only if the updateAllowed property is set to 'true' in the treeSchema or in the treeItem.

Example

The following example shows how the property is used.

<!-- Schema for tree. "changeHandler" is a function that will be called when an item description is changed -->
<script type="cordys/xml" id="schema">
    <TreeSchema>
        <searchPath>//data/tuple/old/</searchPath>
        <Root>
            <description>Employees</description>
        </Root>
        <TreeItem id="EmployeesID">
            <searchPath>Employees</searchPath>
            <description>FirstName</description>
            <updateAllowed>true</updateAllowed>
            <onchange>changeHandler</onchange>
        </TreeItem>
    </TreeSchema>
</script>
// Function call
function changeHandler(changedNode)
{
    <!-- changedNode will contain the node selected, but if updateAllowed is true, then the element involved is a textbox -->
    <!-- Check if the changed description is not empty, and if it is, return without changing -->
    if (event.srcElement.value == "") return false;
}

<!-- tree definition -->
<div cordysType="wcp.library.ui.Tree" id="sampleTree" treeSchema="schema" treeData="data"></div>

See Also

tree, updateAllowed